package com.itheima.dao;

import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface MemberDao_lzl {
    /*
    *根据手机，查询会员
    * */
    @Select("select * from t_member where phoneNumber = #{value}")
    Member findMembertBytelephone(String telephone);

    /*
    * 添加会员信息
    * */
    @Insert("insert into t_member values(#{id},#{fileNumber},#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},#{password},#{email},#{birthday},#{remark})")
    @SelectKey(statement = "select LAST_INSERT_ID()",keyProperty = "id",before = false,resultType = Integer.class)
    Integer addMember(Member member);


    /*
    * 根据当前注册日期查询会员数
    * */
    @Select("select count(*) from t_member where regTime <= #{value}")
    Integer findMemberCountByRegTime(String regTime);
    /*
     * 根据当前注册日期查询获取今天新增会员数
     * */
    @Select("select count(*) from t_member where regTime = #{value}")
    Integer findTodayNewMember(String regTime);
    /*
    * 查询总会员数
    * */
    @Select("select count(*) from t_member")
    Integer getMemberCount();
    /*
    * 查询本周新增会员数
    * */
    @Select("select count(*) from t_member where regTime >=#{value}")
    Integer findNewMember(String date);

    /*
    * 修改会员
    * */
    @Update("update t_member set name=#{name},sex=#{sex},password=#{password},phoneNumber=#{phoneNumber},email=#{email},idCard=#{idCard} where id = #{id}")
    void submitUpdate(Member member);
}
